require 'ajax_scaffold'

class Estimate < ActiveRecord::Base
  belongs_to :task
  validates_presence_of :hours, :date #,:task

  @scaffold_columns = [ 
      AjaxScaffold::ScaffoldColumn.new(self, { :name => "date"}),
      AjaxScaffold::ScaffoldColumn.new(self, { :name => "hours" }),
      AjaxScaffold::ScaffoldColumn.new(self, { :name => "updated_at" }),
      AjaxScaffold::ScaffoldColumn.new(self, { :name => "task", :eval => "estimate.task.name", :sort_sql=> "task_id, date"})
  
  ]
    
  def past?
    today = Time.now.at_midnight
    date.to_time < today
  end
  
  def sprint
    self.task.sprint
  end
  

end
